import 'package:flutter/material.dart';
import 'package:flutter_syt/domain/epidemic/epidemic_health_list.dart';

import '/theme/theme_color.dart';

class ListItemEntity {
  late String leftText;
  late TextStyle leftTextStyle;
  late String? imageUrl;
  late String rightText;
  late Widget? customRight;
  late bool isShowBorder;
  late bool isShowRightIcon;
  late String iconRight;
  late GestureTapCallback? onTap;
  ListItemEntity(
    this.leftText,
    this.imageUrl,
    this.rightText,
    this.onTap, {
    this.isShowBorder = true,
    this.isShowRightIcon = true,
    this.customRight,
    this.iconRight = 'assets/icons/icon_right.png',
    this.leftTextStyle = const TextStyle(
      color: ThemeColor.colorBlack100,
      fontSize: 16,
      // fontWeight: FontWeight.w300,
    ),
  });
}

class ListItem extends StatelessWidget {
  final ListItemEntity listData;
  const ListItem(this.listData) : super();

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTap: listData.onTap,
      child: Padding(
        padding: EdgeInsets.only(left: 15, right: 15),
        child: Container(
          padding: EdgeInsets.fromLTRB(0, 15, 0, 15),
          decoration: BoxDecoration(
            border: listData.isShowBorder
                ? Border(
                    bottom:
                        BorderSide(width: 0.5, color: ThemeColor.dividerColor),
                  )
                : null,
          ),
          child: Row(
            // mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Visibility(
                  visible: listData.imageUrl != null,
                  child: Padding(
                    padding: EdgeInsets.only(right: 10),
                    child: Image.asset(
                      listData.imageUrl ?? '',
                      width: 18,
                    ),
                  )),


              Text(
                "${listData.leftText}",
                style: listData.leftTextStyle,
              ),
              // Row(
              //   children: [

              //   ],
              // ),
              // RichText(
              //   textAlign: TextAlign.center,
              //   text: TextSpan(
              //     children: [
              //       WidgetSpan(
              //           child: listData.imageUrl != null
              //               ? Padding(
              //                   padding: EdgeInsets.only(right: 10),
              //                   child: Image.asset(
              //                     listData.imageUrl ?? '',
              //                     width: 20,
              //                   ),
              //                 )
              //               : Text('')),
              //       TextSpan(
              //         text: "${listData.leftText}",
              //         style: listData.leftTextStyle,
              //       ),
              //     ],
              //   ),
              // ),
              Expanded(
                  child:  Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  // mainAxisAlignment: MainAxisAlignment.spaceAround,
                  // crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    listData.customRight ?? Text(''),
                    Expanded(
                        child: Container(
                      padding: EdgeInsets.only(right: 10, left: 10),
                      child: Text(
                        // 'gdf',
                        "${listData.rightText}",

                        textAlign: TextAlign.right,
                        style: TextStyle(
                          color: ThemeColor.colorBlack100,
                          fontSize: 16,
                          fontWeight: FontWeight.w300,
                        ),
                        maxLines: 2,
                        overflow: TextOverflow.ellipsis,
                      ),
                    )),
                    listData.isShowRightIcon
                        ? Container(
                            padding: EdgeInsets.only(top: 2),
                            alignment: Alignment.center,
                            child: Image.asset(
                              listData.iconRight,
                              width: 8,
                            ),
                          )
                        : Text(''),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
